

<?php $__env->startSection('title', '菜单管理'); ?>

<?php $__env->startSection('content'); ?>
    <style>
        .list-content{
            background-color: #fff;
            max-width: 100%;
            flex: 0 0 100%;
            padding: 0 10px;
        }

        .list-content .tree-content{
            min-width: 600px;
            margin: 0 auto;
            padding: 50px 0px 20px 150px;
            flex: 0 0 auto;
        }

        .list-content .tree-content .tree-row{
            height: 30px;
            line-height: 30px;
        }

        .list-content .tree-content .tree-first:not(:first-child){
            margin-top: 20px;
        }
        .list-content .tree-content .tree-children .tree-second:not(:first-child){
            margin-top: 10px;
        }

    </style>
    <div class="list-content">
        
        <?php echo $__env->make('shared.adminListHeader',[
        'listName'=>'菜单列表',
        'svgIconName' => 'justify',
        'listAddUrl' => url('admin/role/menuEdit'),
        ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
        
        <?php echo $__env->make('shared.adminTreeHeader', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

        <?php if(empty($menuTree)): ?>
        <div class="text-secondary"
             style="padding-top: 50px; line-height: 50px;height: 50px;font-size: 26px;text-align: center;">
            暂无数据
        </div>
        <?php else: ?>
        <div class="tree-content">
            <?php $__currentLoopData = $menuTree; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $firstId=>$firstVal): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="tree-first">
                    <div class="tree-row">
                        <span class="tree-name"><?php echo e($firstVal['name']); ?></span>
                        <span class="text-secondary">序号:<?php echo e($firstVal['row_num']); ?></span>
                        <span class="text-secondary"><?php if(isset($firstVal['is_show']['value']) && 1 == $firstVal['is_show']['value']): ?> 显示于菜单 <?php else: ?> 不显示菜单 <?php endif; ?> </span>
                        <a href="<?php echo e(url('admin/role/menuEdit', ['id'=>$firstId])); ?>">编辑</a>
                        <?php if(empty($firstVal['children'])): ?>
                        <a class="menu-delete" data-id="<?php echo e($firstId); ?>" href="#" >删除</a>
                        <?php endif; ?>
                    </div>
                    <?php if(!empty($firstVal['children'])): ?>
                        <div class="tree-children">
                        <?php $__currentLoopData = $firstVal['children']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $secondId=>$secondVal): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="tree-second">
                                <div class="tree-row">
                                    <span class="tree-name">|--- <?php echo e($secondVal['name']); ?></span>
                                    <span class="text-secondary">序号:<?php echo e($secondVal['row_num']); ?></span>
                                    <span class="text-secondary"><?php if(isset($secondVal['is_show']['value']) && 1 == $secondVal['is_show']['value']): ?> 显示于菜单 <?php else: ?> 不显示菜单 <?php endif; ?> </span>
                                    <a href="<?php echo e(url('admin/role/menuEdit', ['id'=>$secondId])); ?>">编辑</a>
                                    <?php if(empty($secondVal['children'])): ?>
                                        <a class="menu-delete" data-id="<?php echo e($secondId); ?>" href="#">删除</a>
                                    <?php endif; ?>
                                </div>
                                <?php if(!empty($secondVal['children'])): ?>
                                    <div class="tree-children">
                                        <?php $__currentLoopData = $secondVal['children']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $thirdId=>$thirdVal): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <div class="tree-row tree-third">
                                                <span class="tree-name">|---|--- <?php echo e($thirdVal['name']); ?></span>
                                                <span class="text-secondary">序号:<?php echo e($thirdVal['row_num']); ?></span>
                                                <span class="text-secondary"><?php if(isset($thirdVal['is_show']['value']) && 1 == $thirdVal['is_show']['value']): ?> 显示于菜单 <?php else: ?> 不显示菜单 <?php endif; ?> </span>
                                                <a href="<?php echo e(url('admin/role/menuEdit', ['id' => $thirdId])); ?>">编辑</a>
                                                <a class="menu-delete" data-id="<?php echo e($thirdId); ?>" href="#">删除</a>
                                            </div>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </div>
                                <?php endif; ?>
                            </div>

                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                    <?php endif; ?>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
































































































        <?php endif; ?>
    </div>
    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">
    <script>
        $(document).ready(function(){
            $('.menu-delete').on('click', function(){
                let _this = $(this);
                layer.alert('删除后不能恢复，确定继续操作吗？',
                    {
                        title: '删除提示',
                        time: 0, //不自动关闭
                        btn: ['确定', '取消'],
                        yes: function(index){
                            console.log(_this.attr('data-id'));
                            $.ajax({
                                url: "<?php echo e(url('admin/role/menuDelete')); ?>",
                                data: {id:_this.attr('data-id')},
                                dataType: 'json',
                                type: 'POST',
                                headers:{
                                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                },
                                success: function(e){
                                    console.log(e)
                                    if(e.code == 20000){
                                        layer.msg('操作成功');
                                        setTimeout(function(){
                                            window.location.reload();
                                        }, 2000);
                                    } else {
                                        layer.msg(e.msg);
                                    }
                                },
                                error: function(e){
                                    let errorMessage = e.responseText;
                                    errorMessage = errorMessage ? JSON.parse(errorMessage) : [];
                                    errorMessage = errorMessage.message ? errorMessage.message : '系统暂时关闭';
                                    layer.msg(errorMessage);
                                }
                            });
                        }
                    })
            })
        });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layout.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH F:\wamp64\www\laravel8\resources\views/admin/role/menuIndex.blade.php ENDPATH**/ ?>